﻿using CloudStorageLight.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CloudStorageLight.Web.Models
{
    public static class BlobDirectoryExtension
    {



        public static IEnumerable<string> GetRecommendRoles(this BlobDirectory @this)
        {
            if (!@this.Metadata.ContainsKey("RecommendRoles")) return new List<string>();
            return @this.Metadata["RecommendRoles"].Split(',').Select(x => x.Trim());
        } 

        public static void SetRecommendRoles(this BlobDirectory @this, IEnumerable<string> value)
        {
            if (value != null)
            {
                @this.Metadata["RecommendRoles"] = string.Join(",", value);
            }
            else
            {
                if (!@this.Metadata.ContainsKey("RecommendRoles")) @this.Metadata.Remove("RecommendRoles");
            }
        }

    }
}